home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume3 / awm2 / part09 < prev    next >
Encoding:
Internet Message Format  |  1989-02-20  |  55.2 KB

  1. Path: uunet!lll-winken!ames!pasteur!ucbvax!decwrl!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v03i025:  Ardent Window Manager, Patchlevel 9, Part09/12
  5. Message-ID: <2075@wyse.wyse.com>
  6. Date: 20 Feb 89 22:25:15 GMT
  7. Organization: Wyse Technology, San Jose
  8. Lines: 1908
  9. Approved: mikew@wyse.com
  10.  
  11. Submitted-by: kmw@ardent (Ken Wallich)  
  12. Posting-number: Volume 3, Issue 25
  13. Archive-name: awm2/part09
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 9 (of 12)."
  22. # Contents:  FocusChng.c Iconify.c MoveOpaque.c Push.c StoreBox.c
  23. #   lockscreen.c menu_sup.c menus/arrow_icon.h menus/menu.h
  24. # Wrapped by mikew@wyse on Fri Feb 17 10:50:31 1989
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'FocusChng.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'FocusChng.c'\"
  28. else
  29. echo shar: Extracting \"'FocusChng.c'\" \(6267 characters\)
  30. sed "s/^X//" >'FocusChng.c' <<'END_OF_FILE'
  31. X
  32. X
  33. X
  34. X#ifndef lint
  35. Xstatic char *rcsid_FocusChng_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/FocusChng.c,v 1.2 89/02/07 20:04:50 jkh Exp $";
  36. X#endif    lint
  37. X
  38. X#include "X11/copyright.h"
  39. X/*
  40. X *
  41. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  42. X *
  43. X * Copyright 1987 by Jordan Hubbard.
  44. X *
  45. X *
  46. X *                         All Rights Reserved
  47. X *
  48. X * Permission to use, copy, modify, and distribute this software and its
  49. X * documentation for any purpose and without fee is hereby granted,
  50. X * provided that the above copyright notice appear in all copies and that
  51. X * both that copyright notice and this permission notice appear in
  52. X * supporting documentation, and that the name of Ardent Computer
  53. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  54. X * pertaining to distribution of the software without specific, written
  55. X * prior permission.
  56. X *
  57. X */
  58. X
  59. X/*
  60. X * MODIFICATION HISTORY
  61. X *
  62. X * 001 -- Jordan Hubbard, U.C. Berkeley.
  63. X *   Hacks for autoraise and titles.
  64. X * 002 -- Jordan Hubbard, Ardent Computer
  65. X *   Window pixmap changes on focus in/out.
  66. X * 1.4 -- Fixed Focus In/Out handling. Created LightsOn() and LightsOff()
  67. X * to break out the actual process of "highlighting".
  68. X * 1.5 -- Added dynamic installation of colormaps.
  69. X */
  70. X
  71. X
  72. X#include "awm.h"
  73. X
  74. X#ifdef PCS
  75. X#include <bsd/sys/time.h>
  76. X#endif /* PCS */
  77. X#ifdef titan
  78. X#include <sys/time.h>
  79. X#endif /* titan */
  80. X
  81. XWindow FocusWindow;
  82. X
  83. XHandleFocusIn(ev)
  84. XXEvent *ev;
  85. X{
  86. X     XEnterWindowEvent *e = (XEnterWindowEvent *)ev;
  87. X     Window w = e->window;
  88. X     AwmInfoPtr awi;
  89. X     XEvent event;
  90. X
  91. X     Entry("HandleFocusIn")
  92. X
  93. X     if (!(Hilite || Autoraise || InstallColormap) || Snatched)
  94. X     Leave(FALSE)
  95. X
  96. X     awi = GetAwmInfo(w);
  97. X     if (!awi)  /* probably a menu or something */
  98. X         Leave(FALSE)
  99. X     w = (FrameFocus && awi->frame) ? awi->frame : awi->client;
  100. X
  101. X     if (e->detail != NotifyInferior && (e->focus || FrameFocus)) {
  102. X      struct timeval foo;
  103. X
  104. X      if (e->type != FocusIn) {
  105. X           foo.tv_sec = 0;
  106. X           foo.tv_usec = RaiseDelay * 1000; 
  107. X           /*
  108. X        * Sleep for awhile to avoid race conditions and give any
  109. X        * potential leave events a chance to get here..
  110. X        */
  111. X           select(0, 0, 0, 0, &foo);
  112. X           /* Did we leave this window already? */
  113. X           if (XCheckTypedWindowEvent(dpy, w, LeaveNotify, &event))
  114. X            if (event.xcrossing.detail != NotifyInferior)
  115. X             Leave(FALSE)
  116. X           /*
  117. X        * Install a colormap, if necessary.
  118. X        */
  119. X           if (InstallColormap) {
  120. X            XWindowAttributes xwa;
  121. X
  122. X            XGetWindowAttributes(dpy, w, &xwa);
  123. X            XInstallColormap(dpy, xwa.colormap);
  124. X           }
  125. X
  126. X           /*
  127. X        * If Autoraise is set, raise that puppy..
  128. X        */
  129. X           if  (Autoraise && (awi->attrs & AT_RAISE))
  130. X            XRaiseWindow(dpy, (awi->frame) ? awi->frame : awi->client);
  131. X
  132. X           if (!FocusSetByUser && FocusWindow != awi->client &&
  133. X           (awi->attrs & AT_INPUT)) {
  134. X            if (FrameFocus) {
  135. X             XSetInputFocus(dpy, awi->client, RevertToPointerRoot,
  136. X                    CurrentTime);
  137. X             FocusSetByWM = TRUE;
  138. X            }
  139. X            FocusWindow = awi->client;
  140. X           }
  141. X           else
  142. X            Leave(FALSE)
  143. X      }
  144. X      else {
  145. X           FocusWindow = awi->client;
  146. X           FocusSetByWM = FALSE;
  147. X      }
  148. X      LightsOn(awi);
  149. X     }
  150. X     Leave(FALSE)
  151. X}
  152. X
  153. XHandleFocusOut(ev)
  154. XXEvent *ev;
  155. X{
  156. X     XLeaveWindowEvent *e = (XEnterWindowEvent *)ev;
  157. X     Window w = e->window;
  158. X     AwmInfoPtr awi;
  159. X     XEvent event;
  160. X
  161. X     Entry("HandleFocusOut")
  162. X
  163. X     awi = GetAwmInfo(w);
  164. X     if (!awi) /* probably a menu or something */
  165. X         Leave(FALSE)
  166. X
  167. X     if (!(Hilite || Autoraise || InstallColormap) || Snatched)
  168. X     Leave(FALSE)
  169. X
  170. X     w =  (FrameFocus && awi->frame) ? awi->frame : awi->client;
  171. X
  172. X     if (e->detail != NotifyInferior && (e->focus || FrameFocus)) {
  173. X      if (e->type != FocusOut) {
  174. X           /* Did we come back into this window? */
  175. X           if (XCheckTypedWindowEvent(dpy, w, EnterNotify, &event)) {
  176. X            if (event.xcrossing.detail != NotifyInferior)
  177. X             Leave(FALSE)
  178. X           }
  179. X           if (!FocusSetByUser) {
  180. X            if (FrameFocus) {
  181. X             XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot,
  182. X                    CurrentTime);
  183. X             FocusSetByWM = TRUE;
  184. X            }
  185. X            FocusWindow = RootWindow(dpy, scr);
  186. X           }
  187. X           else
  188. X            Leave(FALSE)
  189. X      }
  190. X      else {
  191. X           FocusWindow = RootWindow(dpy, scr);
  192. X           FocusSetByWM = FALSE;
  193. X      }
  194. X      if (InstallColormap)
  195. X           XInstallColormap(dpy, DefaultColormap(dpy, scr));
  196. X      LightsOff(awi);
  197. X     }
  198. X     Leave(FALSE)
  199. X}
  200. X
  201. X/*
  202. X * Turns higlighting off for a window. Counterpart to LightsOn
  203. X */
  204. XLightsOff(awi)
  205. XAwmInfoPtr awi;
  206. X{
  207. X     Entry("LightsOff")
  208. X
  209. X     /* set the window border to "gray" stipple */
  210. X     if (awi->attrs & AT_INPUT) {
  211. X#ifndef RAINBOW
  212. X      if (BorderHilite)
  213. X           SetBorderPixmaps(awi, GrayPixmap);
  214. X#else
  215. X      if (BorderHilite)
  216. X           SetBorderPixmaps(awi, awi->grayPixmap);
  217. X#endif
  218. X      if (awi->frame) {
  219. X           if (awi->back && awi->title)
  220. X            XSetWindowBackgroundPixmap(dpy, awi->title,
  221. X                           awi->back);
  222. X           if (awi->BC_back && (awi->attrs & AT_BORDER)) {
  223. X            XSetWindowBackgroundPixmap(dpy, awi->frame,
  224. X                           awi->BC_back);
  225. X            XClearWindow(dpy, awi->frame);
  226. X           }
  227. X           PaintTitle(awi->title, FALSE);
  228. X      }
  229. X      XSync(dpy, 0);
  230. X     }
  231. X     Leave(FALSE)
  232. X}
  233. X
  234. X
  235. X/*
  236. X * Highlight a window. This may involve shuffling pixmaps around
  237. X * and affecting more than just the client window.
  238. X */
  239. XLightsOn(awi)
  240. XAwmInfoPtr awi;
  241. X{
  242. X     Entry("LightsOn")
  243. X
  244. X     if (awi->attrs & AT_INPUT) {
  245. X#ifndef RAINBOW
  246. X      if (BorderHilite)
  247. X           SetBorderPixmaps(awi, SolidPixmap);
  248. X#else
  249. X      if (BorderHilite)
  250. X           SetBorderPixmaps(awi, awi->solidPixmap);
  251. X#endif
  252. X      if (awi->frame) {
  253. X           if (awi->bold && awi->title) {
  254. X            XSetWindowBackgroundPixmap(dpy, awi->title,
  255. X                           awi->bold);
  256. X            PaintTitle(awi->title, TRUE);
  257. X           }
  258. X           if (awi->BC_bold && (awi->attrs & AT_BORDER)) {
  259. X            XSetWindowBackgroundPixmap(dpy, awi->frame,
  260. X                           awi->BC_bold);
  261. X            XClearWindow(dpy, awi->frame);
  262. X           }
  263. X           XSync(dpy, 0);
  264. X      }
  265. X     }
  266. X     Leave(FALSE)
  267. X}
  268. X
  269. Xvoid SetBorderPixmaps(awi, pix)
  270. XAwmInfoPtr awi;
  271. XPixmap pix;
  272. X{
  273. X     Entry("SetBorderPixmaps")
  274. X
  275. X     XSetWindowBorderPixmap(dpy, awi->client, pix);
  276. X     if (awi->frame) {
  277. X      if (awi->title)
  278. X          XSetWindowBorderPixmap(dpy, awi->title, pix);
  279. X      XSetWindowBorderPixmap(dpy, awi->frame, pix);
  280. X     }
  281. X     Leave_void
  282. X}
  283. END_OF_FILE
  284. if test 6267 -ne `wc -c <'FocusChng.c'`; then
  285.     echo shar: \"'FocusChng.c'\" unpacked with wrong size!
  286. fi
  287. # end of 'FocusChng.c'
  288. fi
  289. if test -f 'Iconify.c' -a "${1}" != "-c" ; then 
  290.   echo shar: Will not clobber existing file \"'Iconify.c'\"
  291. else
  292. echo shar: Extracting \"'Iconify.c'\" \(7543 characters\)
  293. sed "s/^X//" >'Iconify.c' <<'END_OF_FILE'
  294. X
  295. X
  296. X
  297. X#ifndef lint
  298. Xstatic char *rcsid_Iconify_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Iconify.c,v 1.2 89/02/07 20:05:12 jkh Exp $";
  299. X#endif  lint
  300. X
  301. X#include "X11/copyright.h"
  302. X/*
  303. X *
  304. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  305. X *
  306. X * Copyright 1987 by Jordan Hubbard.
  307. X *
  308. X *
  309. X *                         All Rights Reserved
  310. X *
  311. X * Permission to use, copy, modify, and distribute this software and its
  312. X * documentation for any purpose and without fee is hereby granted,
  313. X * provided that the above copyright notice appear in all copies and that
  314. X * both that copyright notice and this permission notice appear in
  315. X * supporting documentation, and that the name of Ardent Computer
  316. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  317. X * pertaining to distribution of the software without specific, written
  318. X * prior permission.
  319. X *
  320. X */
  321. X
  322. X/*
  323. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  324. X *
  325. X *                         All Rights Reserved
  326. X *
  327. X * Permission to use, copy, modify, and distribute this software and its
  328. X * documentation for any purpose and without fee is hereby granted,
  329. X * provided that the above copyright notice appear in all copies and that
  330. X * both that copyright notice and this permission notice appear in
  331. X * supporting documentation, and that the name of Digital Equipment
  332. X * Corporation not be used in advertising or publicity pertaining to
  333. X * distribution of the software without specific, written prior permission.
  334. X *
  335. X *
  336. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  337. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  338. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  339. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  340. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  341. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  342. X * SOFTWARE.
  343. X */
  344. X
  345. X
  346. X
  347. X/*
  348. X * MODIFICATION HISTORY
  349. X *
  350. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  351. X * 001 -- R. Kittell, DEC Storage A/D May 20, 1986
  352. X *  Add optional warp of mouse to the upper right corner on de-iconify,
  353. X *  and to the icon center on iconify.
  354. X * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  355. X *  Western Software Lab. Port to X11.
  356. X * 003 -- Jordan Hubbard, Ardent Computer.
  357. X *  Many mods to cope with context manager, titled windows. Almost a total
  358. X *  rewrite.
  359. X * 1.2 -- Support for IconLabels.. (Isaac Salzman). A few fixes (jkh).
  360. X */
  361. X
  362. X#include "awm.h"
  363. X
  364. XBoolean Iconify(window, mask, button, x, y)
  365. XWindow window;                          /* Event window. */
  366. Xint mask;                               /* Button/key mask. */
  367. Xint button;                             /* Button event detail. */
  368. Xint x, y;                               /* Event mouse position. */
  369. X{
  370. X     XWindowAttributes fromInfo;    /* info on "from" window */
  371. X     XWindowAttributes toInfo;        /* info on "to" window */
  372. X     int mse_x, mse_y;            /* Mouse X and Y coordinates. */
  373. X     int sub_win_x, sub_win_y;        /* relative Mouse coordinates. */
  374. X     int num_vectors;            /* Number of vectors in zap buffer. */
  375. X     unsigned int mmask;            /* Mouse state */
  376. X     Window root;            /* Mouse root window. */
  377. X     Window from, to;            /* from -> to windows */
  378. X     Window sub_win;            /* Mouse position sub-window. */
  379. X     XSegment zap[MAX_ZAP_VECTORS];    /* Zap effect vertex buffer. */
  380. X     Boolean dozap;            /* local Zap */
  381. X     AwmInfoPtr awi;
  382. X     extern Window MakeIcon();
  383. X
  384. X     Entry("Iconify")
  385. X
  386. X     /*
  387. X      * Do not try to iconify the root window.
  388. X      */
  389. X     if (window == RootWindow(dpy, scr))
  390. X      Leave(FALSE)
  391. X     /*
  392. X      * The original idea of zap lines has one flaw. If a window wants
  393. X      * to be created iconic, it should just appear that way without any
  394. X      * fuss. CheckMap() calls us with (win, 0, 0, 0, 0) when this is the
  395. X      * case, so we can special case this to turn off Zap temporarily.
  396. X      * Since we don't want to mess with the global "Zap", we use
  397. X      * "dozap" instead. 
  398. X      */
  399. X     dozap = (mask || button || x || y) ? Zap : FALSE;
  400. X     /*
  401. X      * Clear the vector buffer.
  402. X      */
  403. X     if (dozap)
  404. X      bzero(zap, sizeof(zap));
  405. X     
  406. X     /*
  407. X      * Get the mouse cursor position in case we must put a new
  408. X      * icon there.
  409. X      */
  410. X     XQueryPointer(dpy, RootWindow(dpy, scr), &root, &sub_win, 
  411. X           &mse_x, &mse_y, &sub_win_x, &sub_win_y, &mmask);
  412. X     
  413. X     
  414. X     /*
  415. X      * Figure out which direction we're going in (icon->window or vica-versa)
  416. X      */
  417. X     awi = GetAwmInfo(window);
  418. X     if (!awi)
  419. X          Leave(FALSE)
  420. X     if (awi->state & ST_ICON) {
  421. X          from = awi->icon;
  422. X          to = (awi->frame) ? awi->frame : awi->client;
  423. X      if (!(awi->state & ST_PLACED)) {
  424. X           PlaceWindow(to, None);
  425. X           XMapWindow(dpy, awi->client);
  426. X      }
  427. X     }
  428. X     else if (awi->state & ST_WINDOW) {
  429. X          from = (awi->frame) ? awi->frame : awi->client;
  430. X          to = (awi->icon) ? awi->icon :  MakeIcon(window, mse_x, mse_y, TRUE);
  431. X     }
  432. X     else {
  433. X          printf("Iconify: Window %x has unknown state '%x'\n",
  434. X         awi->client, awi->state);
  435. X      Leave(FALSE)
  436. X     }
  437. X     status = XGetWindowAttributes(dpy, from, &fromInfo);
  438. X     if (status == FAILURE)
  439. X          Leave(FALSE)
  440. X     status = XGetWindowAttributes(dpy, to, &toInfo);
  441. X     if (status == FAILURE)
  442. X          Leave(FALSE)
  443. X    
  444. X     /*
  445. X      * Store the zap vector buffer.
  446. X      */
  447. X     if (dozap) {
  448. X      num_vectors =
  449. X           StoreZap(zap,
  450. X            fromInfo.x - 1,
  451. X            fromInfo.y - 1,
  452. X            fromInfo.x + fromInfo.width +
  453. X            (fromInfo.border_width << 1),
  454. X            fromInfo.y + fromInfo.height +
  455. X            (fromInfo.border_width << 1),
  456. X            toInfo.x - 1,
  457. X            toInfo.y - 1,
  458. X            toInfo.x + toInfo.width +
  459. X            (toInfo.border_width << 1),
  460. X            toInfo.y + toInfo.height +
  461. X            (toInfo.border_width << 1));
  462. X     }
  463. X     if (awi->state & ST_ICON) {
  464. X      if (!awi->frame)
  465. X           XRemoveFromSaveSet(dpy, awi->client);
  466. X      awi->state ^= ST_ICON;
  467. X      awi->state |= ST_WINDOW;
  468. X#ifdef WMSTATE
  469. X      awi->wm_state.state=NormalState;
  470. X      XChangeProperty(dpy,awi->client,wm_state_atom,wm_state_atom,32,
  471. X              PropModeReplace,(char *) &awi->wm_state,2);
  472. X#endif /* WMSTATE */
  473. X     }
  474. X     else if (awi->state & ST_WINDOW) {
  475. X          XAddToSaveSet(dpy, awi->client);
  476. X      awi->state ^= ST_WINDOW;
  477. X      awi->state |= ST_ICON;
  478. X#ifdef WMSTATE
  479. X      awi->wm_state.state=IconicState;
  480. X      XChangeProperty(dpy,awi->client,wm_state_atom,wm_state_atom,32,
  481. X              PropModeReplace,(char *) &awi->wm_state,2);
  482. X#endif /* WMSTATE */
  483. X     }
  484. X     else
  485. X          fprintf(stderr, "Window state for window %x got munged!\n",
  486. X             awi->client);
  487. X     /*
  488. X      * Map the target.
  489. X      */
  490. X     XMapRaised(dpy, to);
  491. X     if (dozap) {
  492. X      /*
  493. X       * Draw the zap lines.
  494. X       */
  495. X      DrawZap();
  496. X     }
  497. X     /*
  498. X      * Unmap the "from" window.
  499. X      */
  500. X     XUnmapWindow(dpy, from);
  501. X     XFlush(dpy);
  502. X     /*
  503. X      * Optionally warp the mouse to the upper right corner of the
  504. X      *  window.
  505. X      */
  506. X     if (WarpOnDeIconify && awi->state & ST_WINDOW) {
  507. X      int y;
  508. X
  509. X      y = (toInfo.height >= 10) ? 10 : toInfo.height / 2;
  510. X      if (awi->frame) { /* compensate for title */
  511. X           XWindowAttributes xwa;
  512. X           XGetWindowAttributes(dpy, awi->title, &xwa);
  513. X           y += xwa.height + 2;
  514. X      }
  515. X      status = XWarpPointer (dpy, None, to,
  516. X                 0, 0, 0, 0,
  517. X                 toInfo.width >= 7 ?
  518. X                 toInfo.width - 7 : toInfo.width / 2,
  519. X                 y);
  520. X     }
  521. X
  522. X     if (WarpOnIconify && awi->state & ST_ICON)
  523. X      status = XWarpPointer (dpy, None, to, 
  524. X                 0, 0, 0, 0,
  525. X                 toInfo.width / 2, toInfo.height / 2);
  526. X     Leave(FALSE)
  527. X}
  528. END_OF_FILE
  529. if test 7543 -ne `wc -c <'Iconify.c'`; then
  530.     echo shar: \"'Iconify.c'\" unpacked with wrong size!
  531. fi
  532. # end of 'Iconify.c'
  533. fi
  534. if test -f 'MoveOpaque.c' -a "${1}" != "-c" ; then 
  535.   echo shar: Will not clobber existing file \"'MoveOpaque.c'\"
  536. else
  537. echo shar: Extracting \"'MoveOpaque.c'\" \(5422 characters\)
  538. sed "s/^X//" >'MoveOpaque.c' <<'END_OF_FILE'
  539. X
  540. X
  541. X
  542. X#ifndef lint
  543. Xstatic char *rcsid_MoveOpaque_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/MoveOpaque.c,v 1.2 89/02/07 21:23:00 jkh Exp $";
  544. X#endif    lint
  545. X
  546. X#include "X11/copyright.h"
  547. X/*
  548. X *
  549. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  550. X *
  551. X * Copyright 1987 by Jordan Hubbard.
  552. X *
  553. X *
  554. X *                         All Rights Reserved
  555. X *
  556. X * Permission to use, copy, modify, and distribute this software and its
  557. X * documentation for any purpose and without fee is hereby granted,
  558. X * provided that the above copyright notice appear in all copies and that
  559. X * both that copyright notice and this permission notice appear in
  560. X * supporting documentation, and that the name of Ardent Computer
  561. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  562. X * pertaining to distribution of the software without specific, written
  563. X * prior permission.
  564. X *
  565. X */
  566. X
  567. X/*
  568. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  569. X *
  570. X *                         All Rights Reserved
  571. X *
  572. X * Permission to use, copy, modify, and distribute this software and its
  573. X * documentation for any purpose and without fee is hereby granted,
  574. X * provided that the above copyright notice appear in all copies and that
  575. X * both that copyright notice and this permission notice appear in
  576. X * supporting documentation, and that the name of Digital Equipment
  577. X * Corporation not be used in advertising or publicity pertaining to
  578. X * distribution of the software without specific, written prior permission.
  579. X *
  580. X *
  581. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  582. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  583. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  584. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  585. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  586. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  587. X * SOFTWARE.
  588. X */
  589. X
  590. X
  591. X
  592. X/*
  593. X * MODIFICATION HISTORY
  594. X *
  595. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  596. X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  597. X * Western Software Lab. Convert to X11.
  598. X * 002 -- Jordan Hubbard, Ardent Computer
  599. X *  Changed to work with awm.
  600. X */
  601. X
  602. X#include "awm.h"
  603. X
  604. X/*ARGSUSED*/
  605. XBoolean MoveOpaque(window, mask, button, x, y)
  606. XWindow window;                /* Event window. */
  607. Xint mask;                /* Button/key mask. */
  608. Xint button;                /* Button event detail. */
  609. Xint x, y;                /* Event mouse position. */
  610. X{
  611. X     int prev_x, prev_y;        /* Previous mouse location. */
  612. X     int rbound, dbound;        /* potential right/down boundries */
  613. X     int cur_x, cur_y;            /* Current mouse location. */
  614. X     int win_x, win_y;            /* Current window location. */
  615. X     int root_x;            /* Root window X location. */
  616. X     int root_y;            /* Root window Y location. */
  617. X     int ptrmask;            /* state of ptr when queried */
  618. X     XWindowAttributes window_info;    /* Event window information. */
  619. X     Window sub_window;            /* Query mouse event sub-window. */
  620. X     Window root;            /* Query mouse event root. */
  621. X     XEvent button_event;        /* Button event packet. */
  622. X     extern void grab_pointer();
  623. X     extern void ungrab_pointer();
  624. X     
  625. X     Entry("MoveOpaque")
  626. X
  627. X     /*
  628. X      * Do not try to move the root window.
  629. X      */
  630. X     if (window == RootWindow(dpy, scr))
  631. X      Leave(FALSE)
  632. X        
  633. X     /*
  634. X      * Change the cursor.
  635. X      */
  636. X     grab_pointer();
  637. X     
  638. X     /*
  639. X      * Gather info on the event window.
  640. X      */
  641. X     status = XGetWindowAttributes(dpy, window, &window_info);
  642. X     if (status == FAILURE)
  643. X      Leave(FALSE)
  644. X
  645. X     /*
  646. X      * Initialize movement variables.
  647. X      */
  648. X     prev_x = cur_x = x;
  649. X     prev_y = cur_y = y;
  650. X     win_x = window_info.x;
  651. X     win_y = window_info.y;
  652. X     rbound = ScreenWidth - (window_info.width + window_info.border_width);
  653. X     dbound = ScreenHeight - (window_info.height + window_info.border_width);
  654. X
  655. X     /*
  656. X      * Main loop.
  657. X      */
  658. X     while (TRUE) {
  659. X      
  660. X      /*
  661. X       * Check to see if we have a change in mouse button status.
  662. X       * This is how we get out of this "while" loop.
  663. X       */
  664. X      if (XCheckMaskEvent(dpy,
  665. X                  ButtonPressMask | ButtonReleaseMask,
  666. X                  &button_event)) {
  667. X           
  668. X           /*
  669. X        * If the button event was something other than the
  670. X        * release of the original button pressed, then move the
  671. X        * window back to where it was originally.
  672. X        */
  673. X           if ((button_event.type != ButtonRelease) ||
  674. X           (((XButtonReleasedEvent *)&button_event)->button
  675. X            != button)) {
  676. X            ResetCursor(button);
  677. X            XMoveWindow(dpy, window, window_info.x, window_info.y);
  678. X           }
  679. X           ungrab_pointer();
  680. X           Leave(TRUE);
  681. X      }
  682. X      
  683. X      /*
  684. X       * Take care of all the little things that have changed; 
  685. X       * i.e., move the window, if necessary.
  686. X       */
  687. X      XQueryPointer(dpy, RootWindow(dpy, scr), 
  688. X            &root, &sub_window, &root_x, &root_y, &cur_x, &cur_y, 
  689. X            &ptrmask);
  690. X      if ((cur_x != prev_x) || (cur_y != prev_y)) {
  691. X           win_x += (cur_x - prev_x);
  692. X           win_y += (cur_y - prev_y);
  693. X#ifdef titan /* align to 5x4 */
  694. X           win_x = ((win_x + 3) / 5) * 5;
  695. X           win_y = ((win_y + 2) / 4) * 4;
  696. X#endif /* titan */
  697. X           if (Wall) {
  698. X            if (win_x < 0)
  699. X             win_x = 0;
  700. X            else if (win_x > rbound)
  701. X             win_x = rbound;
  702. X            if (win_y < 0)
  703. X             win_y = 0;
  704. X            else if (win_y > dbound)
  705. X             win_y = dbound;
  706. X            }
  707. X           XMoveWindow(dpy, window, win_x, win_y);
  708. X           prev_x = cur_x;
  709. X           prev_y = cur_y;
  710. X      }
  711. X     }
  712. X}
  713. END_OF_FILE
  714. if test 5422 -ne `wc -c <'MoveOpaque.c'`; then
  715.     echo shar: \"'MoveOpaque.c'\" unpacked with wrong size!
  716. fi
  717. # end of 'MoveOpaque.c'
  718. fi
  719. if test -f 'Push.c' -a "${1}" != "-c" ; then 
  720.   echo shar: Will not clobber existing file \"'Push.c'\"
  721. else
  722. echo shar: Extracting \"'Push.c'\" \(5313 characters\)
  723. sed "s/^X//" >'Push.c' <<'END_OF_FILE'
  724. X
  725. X
  726. X
  727. X#ifndef lint
  728. Xstatic char *rcsid_Push_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Push.c,v 1.2 89/02/07 21:23:21 jkh Exp $";
  729. X#endif    lint
  730. X
  731. X#include "X11/copyright.h"
  732. X/*
  733. X *
  734. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  735. X *
  736. X * Copyright 1987 by Jordan Hubbard.
  737. X *
  738. X *
  739. X *                         All Rights Reserved
  740. X *
  741. X * Permission to use, copy, modify, and distribute this software and its
  742. X * documentation for any purpose and without fee is hereby granted,
  743. X * provided that the above copyright notice appear in all copies and that
  744. X * both that copyright notice and this permission notice appear in
  745. X * supporting documentation, and that the name of Ardent Computer
  746. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  747. X * pertaining to distribution of the software without specific, written
  748. X * prior permission.
  749. X *
  750. X */
  751. X
  752. X/*
  753. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  754. X *
  755. X *                         All Rights Reserved
  756. X *
  757. X * Permission to use, copy, modify, and distribute this software and its
  758. X * documentation for any purpose and without fee is hereby granted,
  759. X * provided that the above copyright notice appear in all copies and that
  760. X * both that copyright notice and this permission notice appear in
  761. X * supporting documentation, and that the name of Digital Equipment
  762. X * Corporation not be used in advertising or publicity pertaining to
  763. X * distribution of the software without specific, written prior permission.
  764. X *
  765. X *
  766. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  767. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  768. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  769. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  770. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  771. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  772. X * SOFTWARE.
  773. X */
  774. X
  775. X
  776. X/*
  777. X * MODIFICATION HISTORY
  778. X *
  779. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  780. X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  781. X    Western Software Lab. Convert to X11.
  782. X */
  783. X
  784. X#include "awm.h"
  785. X
  786. X#define SHOVE_DOWN    1
  787. X#define SHOVE_UP        2
  788. X#define SHOVE_LEFT    3
  789. X#define SHOVE_RIGHT    4
  790. X
  791. Xextern Boolean ShoveAll();
  792. X
  793. X/*ARGSUSED*/
  794. XBoolean ShoveDown(window, mask, button, x, y)
  795. XWindow window;                /* Event window. */
  796. Xint mask;                /* Button/key mask. */
  797. Xint button;                /* Button event detail. */
  798. Xint x, y;                /* Event mouse position. */
  799. X{
  800. X    Entry("ShoveDown")
  801. X
  802. X    Leave(ShoveAll(window, SHOVE_DOWN))
  803. X}
  804. X
  805. X/*ARGSUSED*/
  806. XBoolean ShoveUp(window, mask, button, x, y)
  807. XWindow window;                /* Event window. */
  808. Xint mask;                /* Button/key mask. */
  809. Xint button;                /* Button event detail. */
  810. Xint x, y;                /* Event mouse position. */
  811. X{
  812. X    Entry("ShoveUp")
  813. X
  814. X    Leave(ShoveAll(window, SHOVE_UP))
  815. X}
  816. X
  817. X/*ARGSUSED*/
  818. XBoolean ShoveLeft(window, mask, button, x, y)
  819. XWindow window;                /* Event window. */
  820. Xint mask;                /* Button/key mask. */
  821. Xint button;                /* Button event detail. */
  822. Xint x, y;                /* Event mouse position. */
  823. X{
  824. X    Entry("ShoveLeft")
  825. X
  826. X    Leave(ShoveAll(window, SHOVE_LEFT))
  827. X}
  828. X
  829. X/*ARGSUSED*/
  830. XBoolean ShoveRight(window, mask, button, x, y)
  831. XWindow window;                /* Event window. */
  832. Xint mask;                /* Button/key mask. */
  833. Xint button;                /* Button event detail. */
  834. Xint x, y;                /* Event mouse position. */
  835. X{
  836. X    Entry("ShoveRight")
  837. X
  838. X    Leave(ShoveAll(window, SHOVE_RIGHT))
  839. X}
  840. X
  841. XBoolean ShoveAll(w, direction)
  842. XWindow w;
  843. Xint direction;
  844. X{
  845. X    XWindowAttributes winfo;            /* Event window information. */
  846. X    int xofs, yofs;            /* Movement offsets. */
  847. X    int x, y;                /* New window position. */
  848. X
  849. X    Entry("ShoveAll")
  850. X
  851. X    /*
  852. X     * Do not try to move the root window.
  853. X     */
  854. X    if (w == RootWindow(dpy, scr))
  855. X        Leave(FALSE)
  856. X
  857. X    /*
  858. X     * Gather info on the event window.
  859. X     */
  860. X    status = XGetWindowAttributes(dpy, w, &winfo);
  861. X    if (status == FAILURE) Leave(FALSE)
  862. X    if (!Pushval && Push)
  863. X     Pushval = DEF_PUSH;
  864. X
  865. X    /*
  866. X     * Calculate the movement offsets.
  867. X     */
  868. X    switch(direction) {
  869. X    case SHOVE_DOWN:
  870. X        xofs = 0;
  871. X        yofs = Push ? (winfo.height / Pushval) : Pushval;
  872. X        break;
  873. X    case SHOVE_UP:
  874. X        xofs = 0;
  875. X        yofs = 0 - (Push ? (winfo.height / Pushval) : Pushval);
  876. X        break;
  877. X    case SHOVE_LEFT:
  878. X        xofs = 0 - (Push ? (winfo.width / Pushval) : Pushval);
  879. X        yofs = 0;
  880. X        break;
  881. X    case SHOVE_RIGHT:
  882. X        xofs = Push ? (winfo.width / Pushval) : Pushval;
  883. X        yofs = 0;
  884. X        break;
  885. X    }
  886. X
  887. X    /*
  888. X     * Calculate the new window position.
  889. X     */
  890. X    x = winfo.x + xofs;
  891. X    y = winfo.y + yofs;
  892. X
  893. X    /*
  894. X     * Normalize the new window coordinates so we don't
  895. X     * lose the window off the edge of the screen.
  896. X     */
  897. X    if (x < (0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1)))
  898. X        x = 0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1);
  899. X    if (y < (0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1)))
  900. X        y = 0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1);
  901. X    if (x > (ScreenWidth - CURSOR_WIDTH))
  902. X        x = ScreenWidth - CURSOR_WIDTH;
  903. X    if (y > (ScreenHeight - CURSOR_HEIGHT))
  904. X        y = ScreenHeight - CURSOR_HEIGHT;
  905. X
  906. X    /*
  907. X     * Move the window into place.
  908. X     */
  909. X    XMoveWindow(dpy, w, x, y);
  910. X
  911. X    Leave(FALSE)
  912. X}
  913. END_OF_FILE
  914. if test 5313 -ne `wc -c <'Push.c'`; then
  915.     echo shar: \"'Push.c'\" unpacked with wrong size!
  916. fi
  917. # end of 'Push.c'
  918. fi
  919. if test -f 'StoreBox.c' -a "${1}" != "-c" ; then 
  920.   echo shar: Will not clobber existing file \"'StoreBox.c'\"
  921. else
  922. echo shar: Extracting \"'StoreBox.c'\" \(5241 characters\)
  923. sed "s/^X//" >'StoreBox.c' <<'END_OF_FILE'
  924. X
  925. X
  926. X
  927. X#ifndef lint
  928. Xstatic char *rcsid_StoreBox_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/StoreBox.c,v 1.1 89/01/23 15:34:53 jkh Exp $";
  929. X#endif    lint
  930. X
  931. X#include "X11/copyright.h"
  932. X/*
  933. X *
  934. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  935. X *
  936. X * Copyright 1987 by Jordan Hubbard.
  937. X *
  938. X *
  939. X *                         All Rights Reserved
  940. X *
  941. X * Permission to use, copy, modify, and distribute this software and its
  942. X * documentation for any purpose and without fee is hereby granted,
  943. X * provided that the above copyright notice appear in all copies and that
  944. X * both that copyright notice and this permission notice appear in
  945. X * supporting documentation, and that the name of Ardent Computer
  946. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  947. X * pertaining to distribution of the software without specific, written
  948. X * prior permission.
  949. X *
  950. X */
  951. X
  952. X/*
  953. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  954. X *
  955. X *                         All Rights Reserved
  956. X *
  957. X * Permission to use, copy, modify, and distribute this software and its
  958. X * documentation for any purpose and without fee is hereby granted,
  959. X * provided that the above copyright notice appear in all copies and that
  960. X * both that copyright notice and this permission notice appear in
  961. X * supporting documentation, and that the name of Digital Equipment
  962. X * Corporation not be used in advertising or publicity pertaining to
  963. X * distribution of the software without specific, written prior permission.
  964. X *
  965. X *
  966. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  967. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  968. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  969. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  970. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  971. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  972. X * SOFTWARE.
  973. X */
  974. X
  975. X
  976. X
  977. X/*
  978. X * MODIFICATION HISTORY
  979. X *
  980. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  981. X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
  982. X Western Software Lab. Convert to X11.
  983. X * 002 -- Jordan Hubbard, Ardent Computer
  984. X *  Additional boxes for titled windows.
  985. X */
  986. X
  987. X/*
  988. X *    StoreBox - This subroutine is used by the X Window Manager (xwm)
  989. X *    to store the vertices for the resize / movement box in a vertex list.
  990. X */
  991. X
  992. X#include "awm.h"
  993. X
  994. X/*
  995. X * Store the vertices for the resize movement box (on a titled window)
  996. X * in a vertex list.
  997. X */
  998. Xint StoreTitleBox(box, ulx, uly, lrx, lry)
  999. Xregister XSegment box[];
  1000. Xint ulx;            /* Upper left X coordinate. */
  1001. Xint uly;            /* Upper left Y coordinate. */
  1002. Xint lrx;            /* Lower right X coordinate. */
  1003. Xint lry;            /* Lower right Y coordinate. */
  1004. X{
  1005. X     Entry("StoreTitleBox");
  1006. X     
  1007. X     /*
  1008. X      * Xor in.
  1009. X      */
  1010. X     
  1011. X     box[0].x1 = ulx; box[0].y1 = uly;
  1012. X     box[0].x2 = lrx; box[0].y2 = uly;
  1013. X
  1014. X     box[1].x1 = ulx; box[1].y1 = uly + titleHeight + 2;
  1015. X     box[1].x2 = lrx; box[1].y2 = uly + titleHeight + 2;
  1016. X     
  1017. X     box[2].x1 = lrx; box[2].y1 = uly;
  1018. X     box[2].x2 = lrx; box[2].y2 = lry;
  1019. X     
  1020. X     box[3].x1 = lrx; box[3].y1 = lry;
  1021. X     box[3].x2 = ulx; box[3].y2 = lry;
  1022. X     
  1023. X     box[4].x1 = ulx; box[4].y1 = lry;
  1024. X     box[4].x2 = ulx; box[4].y2 = uly;
  1025. X
  1026. X     
  1027. X     /*
  1028. X      * If we freeze the screen, don't bother to xor out.
  1029. X      */
  1030. X     if (Freeze)
  1031. X      Leave(5)
  1032. X     
  1033. X     /*
  1034. X      * Xor out.
  1035. X      */
  1036. X     box[4].x1 = ulx; box[4].y1 = uly;
  1037. X     box[4].x2 = lrx; box[4].y2 = uly;
  1038. X     
  1039. X     box[5].x1 = ulx; box[5].y1 = uly + titleHeight + 2;
  1040. X     box[5].x2 = lrx; box[5].y2 = uly + titleHeight + 2;
  1041. X     
  1042. X     box[6].x1 = lrx; box[6].y1 = uly;
  1043. X     box[6].x2 = lrx; box[6].y2 = lry;
  1044. X     
  1045. X     box[7].x1 = lrx; box[7].y1 = lry;
  1046. X     box[7].x2 = ulx; box[7].y2 = lry;
  1047. X     
  1048. X     box[8].x1 = ulx; box[8].y1 = lry;
  1049. X     box[8].x2 = ulx; box[8].y2 = uly;
  1050. X     
  1051. X     
  1052. X     /*
  1053. X      * Total number of vertices is 9.
  1054. X      */
  1055. X     Leave(9)
  1056. X}
  1057. X
  1058. X/*
  1059. X * Store the vertices for the resize movement box in a vertex list.
  1060. X */
  1061. Xint StoreBox(box, ulx, uly, lrx, lry)
  1062. Xregister XSegment box[];
  1063. Xint ulx;            /* Upper left X coordinate. */
  1064. Xint uly;            /* Upper left Y coordinate. */
  1065. Xint lrx;            /* Lower right X coordinate. */
  1066. Xint lry;            /* Lower right Y coordinate. */
  1067. X{
  1068. X     Entry("StoreBox");
  1069. X     
  1070. X     /*
  1071. X      * Xor in.
  1072. X      */
  1073. X     
  1074. X     box[0].x1 = ulx; box[0].y1 = uly;
  1075. X     box[0].x2 = lrx; box[0].y2 = uly;
  1076. X     
  1077. X     box[1].x1 = lrx; box[1].y1 = uly;
  1078. X     box[1].x2 = lrx; box[1].y2 = lry;
  1079. X     
  1080. X     box[2].x1 = lrx; box[2].y1 = lry;
  1081. X     box[2].x2 = ulx; box[2].y2 = lry;
  1082. X     
  1083. X     box[3].x1 = ulx; box[3].y1 = lry;
  1084. X     box[3].x2 = ulx; box[3].y2 = uly;
  1085. X     
  1086. X     
  1087. X     /*
  1088. X      * If we freeze the screen, don't bother to xor out.
  1089. X      */
  1090. X     if (Freeze)
  1091. X      Leave(4)
  1092. X     
  1093. X     /*
  1094. X      * Xor out.
  1095. X      */
  1096. X     box[4].x1 = ulx; box[4].y1 = uly;
  1097. X     box[4].x2 = lrx; box[4].y2 = uly;
  1098. X     
  1099. X     box[5].x1 = lrx; box[5].y1 = uly;
  1100. X     box[5].x2 = lrx; box[5].y2 = lry;
  1101. X     
  1102. X     box[6].x1 = lrx; box[6].y1 = lry;
  1103. X     box[6].x2 = ulx; box[6].y2 = lry;
  1104. X     
  1105. X     box[7].x1 = ulx; box[7].y1 = lry;
  1106. X     box[7].x2 = ulx; box[7].y2 = uly;
  1107. X     
  1108. X     
  1109. X     /*
  1110. X      * Total number of vertices is 8.
  1111. X      */
  1112. X     Leave(8)
  1113. X}
  1114. END_OF_FILE
  1115. if test 5241 -ne `wc -c <'StoreBox.c'`; then
  1116.     echo shar: \"'StoreBox.c'\" unpacked with wrong size!
  1117. fi
  1118. # end of 'StoreBox.c'
  1119. fi
  1120. if test -f 'lockscreen.c' -a "${1}" != "-c" ; then 
  1121.   echo shar: Will not clobber existing file \"'lockscreen.c'\"
  1122. else
  1123. echo shar: Extracting \"'lockscreen.c'\" \(7468 characters\)
  1124. sed "s/^X//" >'lockscreen.c' <<'END_OF_FILE'
  1125. X#ifndef lint
  1126. X     static char sccs_id[] = "%W%  %H%";
  1127. X#endif
  1128. X
  1129. X/*
  1130. X *                             XLOCK V1.4
  1131. X *
  1132. X *                      A Terminal Locker for X11
  1133. X *
  1134. X *              Copyright (c) 1988 by Patrick J. Naughton
  1135. X *
  1136. X *                         All Rights Reserved
  1137. X *
  1138. X * Permission to use, copy, modify, and distribute this software and its
  1139. X * documentation for any purpose and without fee is hereby granted,
  1140. X * provided that the above copyright notice appear in all copies and that
  1141. X * both that copyright notice and this permission notice appear in
  1142. X * supporting documentation.
  1143. X *
  1144. X * Original version posted to comp.windows.x by:
  1145. X * Walter Milliken
  1146. X * (milliken@heron.bbn.com)
  1147. X * BBN Advanced Computers, Inc., Cambridge, MA
  1148. X *
  1149. X * Comments and additions may be sent the author at:
  1150. X *
  1151. X * naughton@sun.soe.clarkson.edu
  1152. X *
  1153. X * or by Snail Mail:
  1154. X * Patrick J. Naughton
  1155. X * 23 Pleasant Street, #3
  1156. X * Potsdam, NY  13676
  1157. X *         or
  1158. X * (315) 265-2853 (voice)
  1159. X *
  1160. X *
  1161. X * Revision History:
  1162. X * 12-Apr-88: Added root password override.
  1163. X *            Added screen saver override.
  1164. X *            Removed XGrabServer/XUngrabServer (Bad idea Phil...)
  1165. X *            Added access control handling instead.
  1166. X * 01-Apr-88: Added XGrabServer/XUngrabServer for more security.
  1167. X * 30-Mar-88: Removed startup password requirement (why did I add that?)
  1168. X *            Removed cursor to avoid phosphor burn.
  1169. X * 27-Mar-88: Rotate fractal by 45 degrees clockwise. (aesthetics)
  1170. X * 23-Mar-88: Added HOPALONG routines from Scientific American Sept. 86 p. 14.
  1171. X *            added password requirement for invokation
  1172. X *            removed option for command line password
  1173. X *            added requirement for display to be "unix:0".
  1174. X * 22-Mar-88: Recieved Walter Milliken's comp.windows.x posting.
  1175. X *
  1176. X * 20-Dec-88: Incorporated into awm. -jkh
  1177. X *
  1178. X */
  1179. X
  1180. X#ifdef LOCKSCR
  1181. X#include <pwd.h>
  1182. X#include <math.h>
  1183. X#include "awm.h"
  1184. X#include <X11/Xutil.h>
  1185. Xchar *crypt();
  1186. Xvoid ReadXString(), lockscreen(), GrabHosts(), UngrabHosts();
  1187. Xvoid iterate(), inithop();
  1188. X
  1189. Xstatic char no_bits[] = {0};
  1190. X
  1191. XWindow w;            /* window used to cover screen */
  1192. XGC gc;
  1193. X
  1194. Xunsigned int width;         /* width of screen */
  1195. Xunsigned int height;        /* height of screen */
  1196. X
  1197. XWindow rootw;            /* root window */
  1198. Xint screen;            /* current screen */
  1199. XColormap cmap;            /* colormap of current screen */
  1200. XCursor mycursor;                /* blank cursor */
  1201. X
  1202. Xunsigned long black_pixel;    /* pixel value for black */
  1203. Xunsigned long white_pixel;    /* pixel value for white */
  1204. XXColor black_color;        /* color value for black */
  1205. XXColor white_color;        /* color value for white */
  1206. X
  1207. Xint centerx, centery, iter, maxiter, range, color;
  1208. Xdouble a, b, c, i, j;
  1209. X
  1210. XDisplay *dsp;
  1211. X
  1212. X
  1213. Xvoid ReadXString(s, slen)
  1214. Xchar *s;
  1215. Xint slen;
  1216. X{
  1217. X     int bp;
  1218. X     char c;
  1219. X     XEvent evt;
  1220. X     XKeyEvent *kpevt = (XKeyEvent *) &evt;
  1221. X     char keystr[20];
  1222. X     
  1223. X     Entry("ReadXString")
  1224. X      
  1225. X     bp = 0;
  1226. X     while (1) {
  1227. X      if (XPending(dsp)) {
  1228. X           XNextEvent(dsp, &evt);
  1229. X           if (evt.type == KeyPress) {
  1230. X            if (XLookupString(kpevt, keystr, 20, (KeySym *) NULL, 
  1231. X                      (XComposeStatus *) NULL) > 0) {
  1232. X             c = keystr[0];
  1233. X             switch (c) {
  1234. X             case 8:            /* ^H */
  1235. X                  if (bp > 0) bp--;
  1236. X                  break;
  1237. X             case 13:        /* ^M */
  1238. X                  s[bp] = '\0';
  1239. X                  Leave_void
  1240. X                  case 21:        /* ^U */
  1241. X                   bp = 0;
  1242. X                  break;
  1243. X             default:
  1244. X                  s[bp] = c;
  1245. X                  if (bp < slen-1) bp++;
  1246. X             }
  1247. X            }
  1248. X           }
  1249. X      }
  1250. X      else iterate();
  1251. X     }
  1252. X     Leave_void
  1253. X}
  1254. X
  1255. X
  1256. Xvoid lockscreen(dpy)
  1257. XDisplay *dpy;
  1258. X{
  1259. X     char buf[10];
  1260. X     char rootpass[10];
  1261. X     XSetWindowAttributes attrs;
  1262. X     XGCValues xgcv;
  1263. X     struct passwd *pw;
  1264. X     Pixmap lockc, lockm;   
  1265. X     int timeout, interval, blanking, exposures; /* screen saver parameters */
  1266. X     extern GC XCreateGC();
  1267. X     
  1268. X     Entry("lockscreen")
  1269. X      
  1270. X     color = GetBoolRes("lock.useColor", FALSE);
  1271. X     dsp = dpy;
  1272. X     
  1273. X     pw = getpwuid(0);
  1274. X     strcpy(rootpass, pw->pw_passwd);
  1275. X     
  1276. X     rootw = DefaultRootWindow(dsp);
  1277. X     screen = DefaultScreen(dsp);
  1278. X     width = DisplayWidth(dsp, screen);
  1279. X     height = DisplayHeight(dsp, screen);
  1280. X     centerx = width / 2;
  1281. X     centery = height / 2;
  1282. X     range = (int) sqrt((double)centerx*centerx+(double)centery*centery);
  1283. X     cmap = DefaultColormap(dsp, screen);
  1284. X     
  1285. X     black_pixel = BlackPixel(dsp, screen);
  1286. X     black_color.pixel = black_pixel;
  1287. X     XQueryColor(dsp, cmap, &black_color);
  1288. X     
  1289. X     white_pixel = WhitePixel(dsp, screen);
  1290. X     white_color.pixel = white_pixel;
  1291. X     XQueryColor(dsp, cmap, &white_color);
  1292. X     
  1293. X     attrs.background_pixel = black_pixel;
  1294. X     attrs.override_redirect = True;
  1295. X     attrs.event_mask = KeyPressMask;
  1296. X     w = XCreateWindow(dsp, rootw, 0, 0, width, height, 0,
  1297. X               CopyFromParent, InputOutput, CopyFromParent,
  1298. X               CWOverrideRedirect | CWBackPixel | CWEventMask, &attrs);
  1299. X     
  1300. X     lockc = XCreateBitmapFromData(dsp, w, no_bits, 8, 1);
  1301. X     lockm = XCreateBitmapFromData(dsp, w, no_bits, 8, 1);
  1302. X     mycursor = XCreatePixmapCursor(dsp, lockc, lockm,
  1303. X                    &black_color, &black_color,
  1304. X                    0, 0);
  1305. X     XFreePixmap(dsp, lockc);
  1306. X     XFreePixmap(dsp, lockm);
  1307. X     
  1308. X     XMapWindow(dsp, w);
  1309. X     
  1310. X     xgcv.foreground = white_pixel;
  1311. X     xgcv.background = black_pixel;
  1312. X     gc = XCreateGC(dsp, w, GCForeground | GCBackground, &xgcv);
  1313. X     
  1314. X     XGetScreenSaver(dsp, &timeout, &interval, &blanking, &exposures);
  1315. X     XSetScreenSaver(dsp, 0, 0, 0, 0); /* disable screen saver */
  1316. X     
  1317. X     XGrabKeyboard(dsp, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
  1318. X     XGrabPointer(dsp, w, False, -1, GrabModeAsync, GrabModeAsync, None,
  1319. X          mycursor, CurrentTime);
  1320. X     
  1321. X     GrabHosts();
  1322. X     
  1323. X     pw = getpwuid(getuid());
  1324. X     
  1325. X     srandom(time(NULL));
  1326. X     do {
  1327. X      inithop();
  1328. X      ReadXString(buf, 10);
  1329. X     } while ((strcmp(crypt(buf, pw->pw_passwd), pw->pw_passwd))
  1330. X          && (strcmp(crypt(buf, rootpass), rootpass)));
  1331. X     
  1332. X     UngrabHosts();
  1333. X     
  1334. X     XUngrabPointer(dsp, CurrentTime);
  1335. X     XUngrabKeyboard(dsp, CurrentTime);
  1336. X     
  1337. X     XSetScreenSaver(dsp, timeout, interval, blanking, exposures);
  1338. X     XDestroyWindow(dsp, w);
  1339. X     XFlush(dsp);
  1340. X     Leave_void
  1341. X}
  1342. X
  1343. XXHostAddress *hosts;
  1344. Xint num_hosts, state;
  1345. X
  1346. Xvoid GrabHosts()
  1347. X{
  1348. X     Entry("GrabHosts")
  1349. X      
  1350. X     XDisableAccessControl(dsp);
  1351. X     hosts = XListHosts(dsp, &num_hosts, &state);
  1352. X     XRemoveHosts(dsp, hosts, num_hosts);
  1353. X     Leave_void
  1354. X}
  1355. X
  1356. X
  1357. Xvoid UngrabHosts()
  1358. X{
  1359. X     Entry("UngrabHosts")
  1360. X      
  1361. X     XEnableAccessControl(dsp);
  1362. X     XAddHosts(dsp, hosts, num_hosts);
  1363. X     XFree(hosts);
  1364. X     Leave_void
  1365. X}
  1366. X
  1367. X
  1368. Xvoid iterate()
  1369. X{
  1370. X     double oldj;
  1371. X     register int k;
  1372. X     
  1373. X     Entry("iterate")
  1374. X      
  1375. X     for (k=0;k<500;k++) {
  1376. X      oldj = j;
  1377. X      j = a - i;
  1378. X      i = oldj + ((i < 0) ? sqrt(fabs(b*i - c)) : -sqrt(fabs(b*i - c))); 
  1379. X      if (color)
  1380. X           XSetForeground(dsp, gc, (iter % 25) * 10 + 5); 
  1381. X
  1382. X      XDrawPoint(dsp, w, gc,
  1383. X             centerx + (int)(i+j), /* sneaky way to rotate +45 deg. */
  1384. X             centery - (int)(i-j));
  1385. X      iter++;
  1386. X     }
  1387. X     if (iter > maxiter)
  1388. X      inithop();
  1389. X     Leave_void
  1390. X}
  1391. X
  1392. Xvoid inithop()
  1393. X{
  1394. X     Entry("inithop")
  1395. X      
  1396. X     a = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
  1397. X     b = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
  1398. X     c = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
  1399. X     
  1400. X     if (!(random()%3))
  1401. X      a /= 10.0;
  1402. X     if (!(random()%2))
  1403. X      b /= 100.0;
  1404. X     
  1405. X     maxiter = (color?10000+random()%20000:20000+random()%50000);
  1406. X     iter = 0;
  1407. X     i = j = 0.0;
  1408. X     XClearWindow(dsp, w);
  1409. X     Leave_void
  1410. X}
  1411. X#endif LOCKSCR
  1412. X
  1413. END_OF_FILE
  1414. if test 7468 -ne `wc -c <'lockscreen.c'`; then
  1415.     echo shar: \"'lockscreen.c'\" unpacked with wrong size!
  1416. fi
  1417. # end of 'lockscreen.c'
  1418. fi
  1419. if test -f 'menu_sup.c' -a "${1}" != "-c" ; then 
  1420.   echo shar: Will not clobber existing file \"'menu_sup.c'\"
  1421. else
  1422. echo shar: Extracting \"'menu_sup.c'\" \(6302 characters\)
  1423. sed "s/^X//" >'menu_sup.c' <<'END_OF_FILE'
  1424. X
  1425. X
  1426. X
  1427. X#ifndef lint
  1428. Xstatic char *rcsid_menu_sup_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/menu_sup.c,v 1.3 89/02/07 22:40:04 jkh Exp $";
  1429. X#endif  lint
  1430. X
  1431. X#include "X11/copyright.h"
  1432. X/*
  1433. X *
  1434. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1435. X *
  1436. X * Copyright 1987 by Jordan Hubbard.
  1437. X *
  1438. X *
  1439. X *                         All Rights Reserved
  1440. X *
  1441. X * Permission to use, copy, modify, and distribute this software and its
  1442. X * documentation for any purpose and without fee is hereby granted,
  1443. X * provided that the above copyright notice appear in all copies and that
  1444. X * both that copyright notice and this permission notice appear in
  1445. X * supporting documentation, and that the name of Ardent Computer
  1446. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1447. X * pertaining to distribution of the software without specific, written
  1448. X * prior permission.
  1449. X *
  1450. X */
  1451. X
  1452. X#include "awm.h"
  1453. X#include <signal.h>
  1454. X#
  1455. X
  1456. X/* interface functions for RTL menus */
  1457. X
  1458. Xdo_nothing()    /* like it says... */
  1459. X{
  1460. X}
  1461. X
  1462. XBoolean check_booleans(menu, item)
  1463. XRTLMenu menu;
  1464. XRTLMenuItem item;
  1465. X{
  1466. X     Boolean *foo;
  1467. X
  1468. X     Entry("check_booleans")
  1469. X
  1470. X     foo = (Boolean *)RTLMenu_Data(menu, item);
  1471. X     Leave(*foo)
  1472. X}
  1473. X
  1474. XBoolean toggle_booleans(menu, item)
  1475. XRTLMenu menu;
  1476. XRTLMenuItem item;
  1477. X{
  1478. X     Boolean *foo;
  1479. X
  1480. X     Entry("togglet_booleans")
  1481. X
  1482. X     foo = (Boolean *)RTLMenu_Data(menu, item);
  1483. X     *foo = !(*foo);
  1484. X     Leave(*foo)
  1485. X}
  1486. X
  1487. X/*ARGSUSED*/
  1488. Xint do_shell(menu, item, window)    /* Do a shell command */
  1489. XRTLMenu menu;
  1490. XRTLMenuItem item;
  1491. XWindow window;            /* not used */
  1492. X{
  1493. X     char *cmd;
  1494. X     int status, pid, w;
  1495. X     void (*istat)(), (*qstat)();
  1496. X
  1497. X     Entry("do_shell")
  1498. X
  1499. X     cmd = (char *)RTLMenu_Data(menu, item);
  1500. X     if ((pid = fork()) == 0) {
  1501. X      setpgrp(0, getpid());
  1502. X          signal(SIGHUP, SIG_DFL);
  1503. X          signal(SIGQUIT, SIG_DFL);
  1504. X          signal(SIGINT, SIG_DFL);
  1505. X      execl("/bin/sh", "sh", "-c", cmd, 0);
  1506. X      _exit(127);
  1507. X     }
  1508. X     istat = (int (*)())signal(SIGINT, SIG_IGN);
  1509. X     qstat = (int (*)())signal(SIGQUIT, SIG_IGN);
  1510. X     while ((w = wait(&status)) != pid && w != -1);
  1511. X     if (w == -1)
  1512. X      status = -1;
  1513. X     signal(SIGINT, istat);
  1514. X     signal(SIGQUIT, qstat);
  1515. X     Leave(status)
  1516. X}
  1517. X
  1518. X/*ARGSUSED*/
  1519. Xint do_text(menu, item, window)
  1520. XRTLMenu menu;
  1521. XRTLMenuItem item;
  1522. XWindow window;
  1523. X{
  1524. X     char *buff;
  1525. X
  1526. X     Entry("do_text")
  1527. X
  1528. X     buff = (char *)RTLMenu_Data(menu, item);
  1529. X     XStoreBytes(dpy, buff, strlen(buff));
  1530. X     Leave_void
  1531. X}
  1532. X
  1533. X/*ARGSUSED*/
  1534. Xint do_text_nl(menu, item, window)
  1535. XRTLMenu menu;
  1536. XRTLMenuItem item;
  1537. XWindow window;
  1538. X{
  1539. X     char *buff1, *buff2;
  1540. X
  1541. X     Entry("do_text_nl")
  1542. X
  1543. X     buff1 = (char *)RTLMenu_Data(menu, item);
  1544. X     buff2 = (char *)malloc(strlen(buff1) + 2);
  1545. X     strcpy(buff2, buff1);
  1546. X     strcat(buff2, "\n");
  1547. X     XStoreBytes(dpy, buff2, strlen(buff2));
  1548. X     free(buff2);
  1549. X     Leave_void
  1550. X}
  1551. X
  1552. Xint do_awm_func(menu, item, window)
  1553. XRTLMenu menu;
  1554. XRTLMenuItem item;
  1555. XWindow window;
  1556. X{
  1557. X     int x, y, button;
  1558. X     Boolean (*func)();
  1559. X     extern Window Select_Window();
  1560. X
  1561. X     Entry("do_awm_func")
  1562. X
  1563. X     XSync(dpy, FALSE);
  1564. X     if (window == RootWindow(dpy, scr))
  1565. X          window = Select_Window(&x, &y, &button);
  1566. X     func = (Boolean(*)())RTLMenu_Data(menu, item);
  1567. X     Leave((*func)(window, 0, button, x, y))
  1568. X}
  1569. X
  1570. X/*ARGSUSED*/
  1571. Xint do_imm_func(menu, item, window)
  1572. XRTLMenu menu;
  1573. XRTLMenuItem item;
  1574. XWindow window;
  1575. X{
  1576. X     Boolean (*func)();
  1577. X
  1578. X     Entry("do_imm_func")
  1579. X
  1580. X     func = (Boolean(*)())RTLMenu_Data(menu, item);
  1581. X     Leave((*func)(RootWindow(dpy, scr), 0, 0, 0, 0))
  1582. X}
  1583. X
  1584. XMenuInfo *FindMenu(s)
  1585. Xregister char *s;
  1586. X{
  1587. X     MenuLink *ml;
  1588. X
  1589. X     Entry("FindMenu")
  1590. X
  1591. X     for (ml = Menus; ml; ml = ml->next)
  1592. X      if (!strcmp(s, ml->menu->name))
  1593. X           Leave(ml->menu)
  1594. X     Leave((MenuInfo *) 0)
  1595. X}
  1596. X
  1597. XRTLMenu create_menu(m)
  1598. XMenuInfo *m;
  1599. X{
  1600. X     ActionLine *ln;
  1601. X     RTLMenuItem tmp;
  1602. X     MenuInfo *side_menu;
  1603. X
  1604. X     Entry("create_menu")
  1605. X
  1606. X     if (!m)
  1607. X      yyerror("Internal error, create_menu passed null pointer");
  1608. X     /*
  1609. X      * Were we already created? This is possible if we were referenced
  1610. X      * by somebody created before us.
  1611. X      */
  1612. X     if (m->menu)
  1613. X      Leave(m->menu)
  1614. X     m->menu = RTLMenu_Create();
  1615. X     /* make a name (or picture) label for this menu */
  1616. X     tmp = RTLMenu_Append_Call(m->menu, m->name, m->pixmapname, do_nothing, 0);
  1617. X     RTLMenu_Label_Entry(m->menu, tmp);
  1618. X     ln = m->line;
  1619. X     if (!ln) {
  1620. X      yyerror("Internal error in create_menu.");
  1621. X      fprintf(stderr, "Menu '%s' has no line list.\n", m->name);
  1622. X      exit(1);
  1623. X     }
  1624. X     if (!ln->name && !ln->pixmapname) {
  1625. X      fprintf(stderr, "awm: Action in menu '%s' has no name or backing pixmap\n",
  1626. X          m->name);
  1627. X      yyerror(".. aborting\n");
  1628. X      exit(1);
  1629. X     }
  1630. X     while (ln) {
  1631. X      switch (ln->type) {
  1632. X      case IsVar:
  1633. X           ln->item = RTLMenu_Append_Checkback(m->menu, ln->name,
  1634. X                           ln->pixmapname,
  1635. X                           check_booleans,
  1636. X                           toggle_booleans,
  1637. X                           ln->text);
  1638. X           break;
  1639. X           
  1640. X      case IsImmFunction:
  1641. X           ln->item = RTLMenu_Append_Call(m->menu, ln->name,
  1642. X                          ln->pixmapname,
  1643. X                          do_imm_func, ln->func);
  1644. X           break;
  1645. X
  1646. X      case IsUwmFunction:
  1647. X           ln->item = RTLMenu_Append_Call(m->menu, ln->name,
  1648. X                          ln->pixmapname,
  1649. X                          do_awm_func, ln->func);
  1650. X           break;
  1651. X
  1652. X      case IsMenuFunction:
  1653. X           if (!(side_menu = FindMenu(ln->text))) {
  1654. X            fprintf(stderr, "Unknown menu \"%s\" referenced in ",
  1655. X            ln->text);
  1656. X            yyerror(" ..");
  1657. X            exit(1);
  1658. X           }
  1659. X           /* If we haven't created the referenced menu yet, create it now */
  1660. X           if (!side_menu->menu)
  1661. X            side_menu->menu = create_menu(side_menu);
  1662. X           ln->item = RTLMenu_Append_Submenu(m->menu, ln->name,
  1663. X                         ln->pixmapname,
  1664. X                         side_menu->menu);
  1665. X           break;
  1666. X           
  1667. X      case IsText:
  1668. X           ln->item = RTLMenu_Append_Call(m->menu, ln->name,
  1669. X                          ln->pixmapname,
  1670. X                          do_text, ln->text);
  1671. X           break;
  1672. X
  1673. X      case IsTextNL:
  1674. X           ln->item = RTLMenu_Append_Call(m->menu, ln->name,
  1675. X                          ln->pixmapname,
  1676. X                          do_text_nl, ln->text);
  1677. X           break;
  1678. X           
  1679. X      case IsShellCommand:
  1680. X           ln->item = RTLMenu_Append_Call(m->menu, ln->name,
  1681. X                          ln->pixmapname,
  1682. X                          do_shell, ln->text);
  1683. X           break;
  1684. X           
  1685. X      default:
  1686. X           fprintf(stderr, "create_menu, Unknown menu entry type %d\n",
  1687. X          ln->type);
  1688. X           break;
  1689. X      }
  1690. X      free(ln);
  1691. X      ln = ln->next;
  1692. X     }
  1693. X     Leave(m->menu)
  1694. X}
  1695. END_OF_FILE
  1696. if test 6302 -ne `wc -c <'menu_sup.c'`; then
  1697.     echo shar: \"'menu_sup.c'\" unpacked with wrong size!
  1698. fi
  1699. # end of 'menu_sup.c'
  1700. fi
  1701. if test -f 'menus/arrow_icon.h' -a "${1}" != "-c" ; then 
  1702.   echo shar: Will not clobber existing file \"'menus/arrow_icon.h'\"
  1703. else
  1704. echo shar: Extracting \"'menus/arrow_icon.h'\" \(191 characters\)
  1705. sed "s/^X//" >'menus/arrow_icon.h' <<'END_OF_FILE'
  1706. X
  1707. X#define arrow_width 10
  1708. X#define arrow_height 9
  1709. Xstatic char arrow_bits[] = {
  1710. X   0x30, 0x00, 0x60, 0x00, 0xff, 0x00, 0xc0, 0x01, 0x9e, 0x03, 0xc0, 0x01,
  1711. X   0xff, 0x00, 0x60, 0x00, 0x30, 0x00};
  1712. END_OF_FILE
  1713. if test 191 -ne `wc -c <'menus/arrow_icon.h'`; then
  1714.     echo shar: \"'menus/arrow_icon.h'\" unpacked with wrong size!
  1715. fi
  1716. # end of 'menus/arrow_icon.h'
  1717. fi
  1718. if test -f 'menus/menu.h' -a "${1}" != "-c" ; then 
  1719.   echo shar: Will not clobber existing file \"'menus/menu.h'\"
  1720. else
  1721. echo shar: Extracting \"'menus/menu.h'\" \(6154 characters\)
  1722. sed "s/^X//" >'menus/menu.h' <<'END_OF_FILE'
  1723. X
  1724. X/*
  1725. X#ifndef lint
  1726. Xstatic char sccs_id[] = "@(#)menu.h    2.1 12/16/87  Siemens Corporate Research and Support, Inc.";
  1727. X#endif
  1728. X*/
  1729. X
  1730. X
  1731. X/* 
  1732. X  RTL Menu Package Version 1.0
  1733. X  by Joe Camaratta and Mike Berman, Siemens RTL, Princeton NJ, 1987
  1734. X
  1735. X  menu.h: menus header file
  1736. X  based on: menu.h    X10/6.6    11/3/86
  1737. X*/
  1738. X
  1739. X#include "X11/copyright.h"
  1740. X/*
  1741. X *
  1742. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1743. X *
  1744. X * Copyright 1987 by Jordan Hubbard.
  1745. X *
  1746. X *
  1747. X *                         All Rights Reserved
  1748. X *
  1749. X * Permission to use, copy, modify, and distribute this software and its
  1750. X * documentation for any purpose and without fee is hereby granted,
  1751. X * provided that the above copyright notice appear in all copies and that
  1752. X * both that copyright notice and this permission notice appear in
  1753. X * supporting documentation, and that the name of Ardent Computer
  1754. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1755. X * pertaining to distribution of the software without specific, written
  1756. X * prior permission.
  1757. X *
  1758. X */
  1759. X
  1760. X/*
  1761. X
  1762. XCopyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
  1763. X
  1764. XPermission to use, copy, modify, and distribute this
  1765. Xsoftware and its documentation for any purpose and without
  1766. Xfee is hereby granted, provided that the above copyright
  1767. Xnotice appear in all copies and that both that copyright
  1768. Xnotice and this permission notice appear in supporting
  1769. Xdocumentation, and that the name of M.I.T. not be used in
  1770. Xadvertising or publicity pertaining to distribution of the
  1771. Xsoftware without specific, written prior permission.
  1772. XM.I.T. makes no representations about the suitability of
  1773. Xthis software for any purpose.  It is provided "as is"
  1774. Xwithout express or implied warranty.
  1775. X
  1776. X*/
  1777. X
  1778. X/*
  1779. X
  1780. XCopyright 1987 by
  1781. X    Siemens Corporate Research and Support, Inc., Princeton, New Jersey
  1782. X
  1783. XPermission to use, copy, modify, and distribute this
  1784. Xsoftware and its documentation for any purpose and without
  1785. Xfee is hereby granted, provided that the above copyright
  1786. Xnotice appear in all copies and that both that copyright
  1787. Xnotice and this permission notice appear in supporting
  1788. Xdocumentation, and that the name of Siemens not be used in
  1789. Xadvertising or publicity pertaining to distribution of the
  1790. Xsoftware without specific, written prior permission.
  1791. XSiemens makes no representations about the suitability of
  1792. Xthis software for any purpose.  It is provided "as is"
  1793. Xwithout express or implied warranty.
  1794. X
  1795. X*/
  1796. X
  1797. X#ifndef MENU_INCLUDE
  1798. X#define MENU_INCLUDE
  1799. X/*
  1800. X * Menu items are constructed as follows, starting from the left side:
  1801. X *
  1802. X *    menuItemPad
  1803. X *    space for check mark
  1804. X *    menuItemPad
  1805. X *    text + padding
  1806. X *    menuItemPad
  1807. X *
  1808. X * The padding for the text is that amount that this text is narrower than the
  1809. X * widest text.
  1810. X */
  1811. Xextern void Retch();
  1812. X
  1813. X#include "std_defs.h"
  1814. X#include "rtlmnu.opt.h"
  1815. X
  1816. Xtypedef void (*Callback) ();
  1817. Xtypedef struct _menuItem MenuItem;
  1818. Xtypedef struct _menu Menu;
  1819. X
  1820. X/*
  1821. X * Special note for those familiar with the original RTL menus:
  1822. X * Where we used to keep height and width information for items
  1823. X * in the _menu structure, we now just keep width. Each item
  1824. X * can be of a different height, but is still constrained
  1825. X * to a fixed width (which is the width of the widest item in the
  1826. X * menu). We could allow variable widths, but the menu would look
  1827. X * like hell. We also allow arbitrary pixmap backgrounds for each
  1828. X * item now.
  1829. X */
  1830. Xstruct _menuItem {
  1831. X    int itemFlags;            /* flags of item */
  1832. X
  1833. X#define    itemDisabled        0x0001    /* item is disabled */
  1834. X#define    itemChecked        0x0002    /* item has check mark */
  1835. X#define itemDeaf        0x0004    /* item is a label */
  1836. X#define    itemChanged        0x0010    /* item desires change */
  1837. X    Pixmap itemBackground;        /* either zero or a pixmap */
  1838. X    char *itemText;            /* text of item (if no pixmap) */
  1839. X    unsigned int itemTextWidth;    /* width of text (or pixmap) */
  1840. X    unsigned int itemTextLength;    /* length of text */
  1841. X    unsigned int itemHeight;    /* height of this item */
  1842. X    struct _menuItem *nextItem;    /* next item in chain */
  1843. X    struct _menu *itemSubmenu;    /* For pull-right menus  */
  1844. X    Callback generator;        /* Change string and data */
  1845. X    caddr_t genParamPointer;    /* Address for generated parameter */
  1846. X    Boolean (*checkproc) ();    /* Checkmark callback generator */
  1847. X    Callback itemCallback;          /* user callback for item */
  1848. X    pointer itemData;               /* user data associated with menu */
  1849. X        Window  itemWindow;             /* window of item */
  1850. X        Menu *itemMenu;                 /* menu this item belongs to */
  1851. X};
  1852. X
  1853. Xstruct _menu {
  1854. X    unsigned int menuWidth;        /* full width of menu */
  1855. X    unsigned int menuHeight;    /* full height of menu */
  1856. X    unsigned int avgHeight;        /* Hack.. */
  1857. X        unsigned int menuOldWidth;
  1858. X        unsigned int menuOldHeight;
  1859. X        unsigned int menuItemWidth;     /* width of a menu item */
  1860. X    int menuFlags;            /* flags of this menu */
  1861. X
  1862. X# define    menuChanged    0x0001        /* menu changed, must redraw */
  1863. X# define    menuItemChanged    0x0002        /* item changed, must redraw */
  1864. X# define    menuMapped    0x0004        /* menu is now mapped */
  1865. X
  1866. X    unsigned int menuMaxTextWidth;    /* width of widest text */
  1867. X        unsigned int menuOldBorderWidth;
  1868. X    Display *display;        /* display of menu */
  1869. X    int screen;            /* screen on which to display menu */
  1870. X    Window menuWindow;        /* window of menu */
  1871. X    Cursor menuCursor;        /* cursor used in menu */
  1872. X    Pixmap savedPixmap;             /* for saving image under menu */
  1873. X    MenuItem *menuItems;        /* head of menu item chain */
  1874. X    XFontStruct *menuFontInfo;     /* Font info */
  1875. X    XFontStruct *boldFont;
  1876. X    GC normalGC;            /* Graphics contexts */
  1877. X    GC invertGC;            /* Used for inverted text */
  1878. X    GC boldGC;            /* For labels */
  1879. X    Pixmap greyPixmap;        /* Need to know what to free */
  1880. X    Pixmap checkmarkPixmap;        /* Pixmap for drawing check mark. */
  1881. X    Pixmap arrowPixmap;        /* Pixmap for drawing arrow. */
  1882. X    char *menuInitialItemText;      /* != NULL, initial item */
  1883. X    MenuItem *highlightedItem;    /* highlighted menu item */
  1884. X    int menuNested;            /* depth you are nested */
  1885. X    int menuX, menuY;        /* Menu position */
  1886. X        struct _menu *parentMenu;       /* menu to which you are a submenu
  1887. X                                         * (NULL if you are the root)
  1888. X                     */
  1889. X    MenuOptionsMask menuOptions;    /* option values for this menu */
  1890. X    };
  1891. X#endif MENU_INCLUDE
  1892. END_OF_FILE
  1893. if test 6154 -ne `wc -c <'menus/menu.h'`; then
  1894.     echo shar: \"'menus/menu.h'\" unpacked with wrong size!
  1895. fi
  1896. # end of 'menus/menu.h'
  1897. fi
  1898. echo shar: End of archive 9 \(of 12\).
  1899. cp /dev/null ark9isdone
  1900. MISSING=""
  1901. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1902.     if test ! -f ark${I}isdone ; then
  1903.     MISSING="${MISSING} ${I}"
  1904.     fi
  1905. done
  1906. if test "${MISSING}" = "" ; then
  1907.     echo You have unpacked all 12 archives.
  1908.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1909. else
  1910.     echo You still need to unpack the following archives:
  1911.     echo "        " ${MISSING}
  1912. fi
  1913. ##  End of shell archive.
  1914. exit 0
  1915. -- 
  1916. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  1917. Moderator of comp.sources.x
  1918.